package game.resources;

/**
 *	@(#)Resource.java
 *
 *	The <code>Resource</code> class represents a resource.
 *	It is the super class of all resource classes.
 *
 *	@author Grzegorz Kobiela
 *	@version 1.0 2007/9/11
 */
public abstract class Resource
extends game.GameObject
{
	/** The resource type. */
	protected ResourceType type;

	/**
	 *	Creates a new <code>Resource</code> instance.
	 *	@param type the resource type
	 */
	protected Resource(ResourceType type) {
		this.type = type;
	}

	/**
	 *	Returns the resource type.
	 *	@return the resource type
	 */
	public ResourceType getType() {
		return type;
	}

	/**
	 *	Factory method to create resources by their type.
	 *	@param type the resource type
	 */
	public static Resource createResource(ResourceType type) {
		switch(type) {
			case DYE: return new Dye();
			case FISH: return new Fish();
			case GOLD: return new Gold();
			case GRAIN: return new Grain();
			case OLIVES: return new Olives();
			case PEARLS: return new Pearls();
			case SHEEP: return new Sheep();
			case STONE: return new Stone();
			case WINE: return new Wine();
			case WOOD: return new Wood();
			default: throw new IllegalArgumentException(type + " is not supported by Resource.createResource(ResourceType)!");
		}
	}
}